Skip to content

Fix geo latitude inversion unreal coordinates#9552

Open
csonthomisi wants to merge 2 commits intocarla-simulator:ue4-devfrom
csonthomisi:mcsontho/fix-geo-latitude-inversion-unreal-coordinates
Open

Fix geo latitude inversion unreal coordinates#9552
csonthomisi wants to merge 2 commits intocarla-simulator:ue4-devfrom
csonthomisi:mcsontho/fix-geo-latitude-inversion-unreal-coordinates

Conversation

@csonthomisi
Copy link

@csonthomisi csonthomisi commented Feb 13, 2026

Description

This PR fixes a bug in the geo-coordinate conversion system where latitude values changed incorrectly (inverted sign) when moving north/south in maps using Transverse Mercator (tmerc) or Universal Transverse Mercator (UTM) projections without an explicit <offset> tag in the OpenDRIVE file.

Root Cause:
Unreal Engine uses a left-handed coordinate system while geographic projections (Transverse Mercator, UTM) assume a right-handed system. The projection inverse transforms did not account for this handedness mismatch, causing the northing (Y) component to have an inverted sign relative to latitude changes.

Changes Made:

  1. GeoProjection.cpp:
    • Modified TransformToGeoLocationTransverseMercator() to negate the Y-coordinate: double y = -((location.y - p.y_0) / p.k);
    • Modified TransformToGeoLocationUniversalTransverseMercator() to negate the Y-coordinate: double y = -((location.y - y_0) / k);
    • Added comments documenting the fix and the reasoning (Unreal left-handed coordinate system correction, applied 2026-02-13)

Behavior Change:

  • Before: Moving an actor +Y in CARLA local coordinates produced decreasing latitude (incorrect)
  • After: Moving an actor +Y in CARLA local coordinates produces increasing latitude (correct)
  • Map origin (local 0,0) continues to map correctly to the expected geolocation

Fixes #9530 #9389

Where has this been tested?

  • Platform(s): Ubuntu 22.04
  • Python version(s): 3.10
  • Unreal Engine version(s): 4.26 (CARLA ue4-dev branch)
  • Test method: GNSS sensor output validation; confirmed latitude increases when actor moves north

Possible Drawbacks

  • Maps that explicitly use an <offset> transform in OpenDRIVE may need validation to ensure the combined effect (offset negation + projection negation) is correct. However, the offset's OffsetTransform already applies a Y negation, so this change complements existing behavior.
  • Any downstream code that relied on the incorrect (inverted) latitude behavior will need adjustment, but the fix aligns the system with correct geographic coordinate semantics.

Files Changed

  1. LibCarla/source/carla/geom/GeoProjection.cpp

This change is Reviewable

@csonthomisi csonthomisi requested a review from a team as a code owner February 13, 2026 10:18
@csonthomihaly
Copy link

It seems that this is maybe not the best place and solution for this problem. I will try to implement a better solution next week. Until that, this should not be merged! Thanks for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants